package com.interesting.base.core;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.actionbarsherlock.app.SherlockFragment;

public class BaseFragment extends SherlockFragment {
	private boolean isFirstTimeStartFlag = true;

	// when activity is first time start
	protected final int FIRST_TIME_START = 0;
	// when activity is destroyed and recreated because a configuration change,
	// see setRetainInstance(boolean retain)
	protected final int SCREEN_ROTATE = 1;
	// when activity is destroyed because memory is too low, recycled by android
	// system
	protected final int ACTIVITY_DESTROY_AND_CREATE = 2;

	protected int getCurrentState(Bundle savedInstanceState) {

		if (savedInstanceState != null) {
			isFirstTimeStartFlag = false;
			return ACTIVITY_DESTROY_AND_CREATE;
		}

		if (!isFirstTimeStartFlag) {
			return SCREEN_ROTATE;
		}

		isFirstTimeStartFlag = false;
		return FIRST_TIME_START;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {

		getSherlockActivity().getSupportActionBar().setDisplayShowCustomEnabled(true);
		super.onCreate(savedInstanceState);

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

		return super.onCreateView(inflater, container, savedInstanceState);
	}

}
